﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Web.Security;

namespace Simple.Common.Core.Encryption
{
    public static class SimpleMD5Helper
    {
        //public static string GetMD5(string input)
        //{
        //    if (string.IsNullOrEmpty(input)) return string.Empty;

        //    // Use input string to calculate MD5 hash
        //    MD5 md5 = System.Security.Cryptography.MD5.Create();
        //    byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
        //    byte[] hashBytes = md5.ComputeHash(inputBytes);

        //    // Convert the byte array to hexadecimal string
        //    StringBuilder sb = new StringBuilder();
        //    for (int i = 0; i < hashBytes.Length; i++)
        //    {
        //        sb.Append(hashBytes[i].ToString("X2"));
        //    }
        //    return sb.ToString();
        //}

        /// <summary>
        /// MD5加密
        /// </summary>
        /// <param name="input">输入字符串</param>
        /// <returns></returns>
        public static string GetMD5(string input)
        {
            if (string.IsNullOrEmpty(input)) return string.Empty;

            return FormsAuthentication.HashPasswordForStoringInConfigFile(input, "MD5");
        }
    }


}
